import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {h} from "vue";
import { Tag } from 'ant-design-vue';
import {UploadTypeEnum} from "@/components/Form/src/jeecg/components/JUpload";
//列表数据
export const innerColumns: BasicColumn[] = [
  {
    title: '工序',
    align:"center",
    dataIndex: 'process_dictText',
    width: 80,
  },
  {
    title: '状态',
    align:"center",
    dataIndex: 'status_dictColor',
    width: 80,
    customRender:({ text }) => {
      return h('div', {
        style: {"background": text, "width":"18px","height":"18px","border-radius":"50%","margin":"0 auto"}
      })
    }
  },
  {
    title: '状态2',
    align:"center",
    dataIndex: 'status',
    width: 80,
    customRender: function (text) {
      return h(Tag, {
        color: text.record[text.column.dataIndex + "_dictColor"]
      }, text.record[text.column.dataIndex + "_dictText"])
    }
  },

   {
    title: '作业人员',
    align:"center",
    dataIndex: 'userId_dictText',
     width: 80,
   },
  {
    title: '完成日期',
    align:"center",
    dataIndex: 'overTime',
    width: 80,
  },



   {
    title: '备注',
    align:"center",
    dataIndex: 'remark',
     width: 80,
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据  dw_order,order_num,id,status ="1" order by order_num  DESC
export const formSchema: FormSchema[] = [

  {
    label: '工序',
    field: 'process',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'dw_process',   //sys_dict_item ,item_text,id ,dict_id ="1918217753454952450" order by item_value  ASC,  dw_process
    },
    required: true,
  },

  {
    field: 'checkOutImg',
    component: 'JUpload',
    label: '上传检验清单',
    helpMessage: '无限制上传',
    componentProps: {
      fileType: UploadTypeEnum.image,

    },
    show:({model})=>{
      return model.process==='40';
    }
  },
  {
    label: '打包方式',
    field: 'packType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'dw_pack_type',
    },
    show:({model})=>{
      return model.process==='50';
    },
    required: true,
  },


  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'dw_process_status',
    },
    required: true,
  },
  {
    label: "完成日期",
    field: 'overTime',
    component: 'DatePicker',
    componentProps: {
      showTime:false,
      valueFormat: 'YYYY-MM-DD'
    },
    required: true,
    //colProps: {span: 6},
  },

  {
    label: '作业人员',
    field: 'userId',
    component: 'UserSelect',
    componentProps: {
      multi: true,
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 4,
    },
    required: true,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },


	{
	  label: '',
	  field: 'proPlanId',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  status: {title: '装配状态',order: 0,view: 'text', type: 'string',},
  proPlanId: {title: '计划生产单',order: 2,view: 'text', type: 'string',},
  userId: {title: '作业人员',order: 3,view: 'text', type: 'string',},
  remark: {title: '备注',order: 4,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
